"""
File: conftest.py
Author: ershixiong
Date: 2023/12/25
describe:

"""
from typing import List

import pytest

from hogwarts.Wework.utils.log_utils import logger
from hogwarts.Wework.utils.utils import delete_folders_files


@pytest.fixture(scope='session', autouse=True)
def start_and_end():
    logger.debug('测试开始')
    # 删除多个文件夹下多余的文件
    paths = [
        'screen_shot_pic',
        'log_result',
        'result'
    ]

    delete_folders_files(paths)
    yield
    logger.debug('测试结束')


def pytest_collection_modifyitems(
        session: "Session", config: "Config", items: List["Item"]
) -> None:
    for item in items:
        item.name = item.name.encode('utf-8').decode('unicode-escape')
        item._nodeid = item.nodeid.encode('utf-8').decode('unicode-escape')


# todo 整个项目只打开一次浏览器
# @pytest.fixture(scope='session', autouse=True)
# def browser():
#     home = HomePage()
#     # print(home.driver)
#     yield home
#     home.driver.quit()
